﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
Response.Expires = -1
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "Cache-Control", "no-cache, must-revalidate"
Server.ScriptTimeOut = 3600
%>
<card id="login" title="上传文件"><p align="left">
<%
Dim classid,aid,Page,we0,rs,sql,bid,j
we0="<br/>"
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0
    		aid = Request("aid")     
    		If aid = "" Then aid = 1
   		If Not IsNumeric(aid) Then aid = 1
    		aid = CLng(aid)
    		Page = Request("page")     
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
	dim ip,name,content,member
	dim filesize,upfile,AllowFileExt,formPath,i,fileExt,uploadsuc,ranNum,filename,upfilesize,UploadPath,FilePath,errs
	dim FsoObj1,Upload,File,FormName,path,FilePath2
	errs=false
	UploadPath = "/upfileload/"
	FilePath=UploadPath
	dim filetype


	Set Rs = Server.CreateObject("Adodb.Recordset")

	Sql = "SELECT [upfile],[filesize],[format],[filetype] FROM [qingtian_bbs_config]"

	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof) then
		filetype=rs("filetype")
		upfile=rs("upfile")
		upfilesize=rs("filesize")
		AllowFileExt=rs("format")
	else
	end if
	Rs.close
	set rs=nothing


if upfile=true then

	set upload=new upfile_class ''建立上传对象
	upload.GetData(upfilesize*1024)   '取得上传数据,限制最大上传100M

	if upload.err > 0 then  '如果出错
		select case upload.err
			case 1
				%>请先选择你要上传的文件！<%=we0%><%
				%><a href="bbswenjian.asp?dir=<%=dir%>&amp;sid=<%=sidd%>">返回修改</a><%=we0%><%
				errs=true
			case 2
				%>你上传的文件总大小超出了最大限制（<%=upfilesize%>KB）<%=we0%><%
				%><a href="bbswenjian.asp?dir=<%=dir%>&amp;sid=<%=sidd%>">返回修改</a><%=we0%><%
				errs=true
		end select

	end if



			ip=Request.ServerVariables("REMOTE_ADDR")
	AllowFileExt = "jpg|gif|bmp|jpeg|peg|png|jpge|mid|midi|mmf|amr|mp3|aac|wav|wma|mp4|3gp|wmv|jar|jad|rar|sis|sisx|mrp|zip"
AllowFileExt = lcase(AllowFileExt)
if  errs=flase then	
for each formName in upload.file 
EnableUpload=true
		set ofile=upload.file(formName)  '生成一个文件对象	
		upfilename=ofile.FileName		
		oFileSize=ofile.filesize	
		sizes=cstr(round(oFileSize*1024))		
		fileExt=lcase(ofile.FileExt)
    		fileExt=trim(fileExt)
    
    		if fileExt<>"" then
		arrUpFileType=split(AllowFileExt,",")
		for i=0 to ubound(arrUpFileType)
			if fileEXT=trim(arrUpFileType(i)) then
				EnableUpload=true
				exit for
			end if
		next
    		else
  			EnableUpload=true
   		end if

		If Instr(AllowFileExt,Lcase(replace(Fileext,".",""))) <= 0 Then
		 EnableUpload=false
		end if
		if EnableUpload=false then
			%>请选择文件上传！这种文件类型不允许上传:asp|asa|aspx|exe|bat|cer...如果需要上传联系管理员开通(网站基本信息设置)或请先rar（压缩后）再上传<%=we0%><%
				errs=true
		end if
		if oFileSize>(upfilesize*1024) then
      			%>文件大小超过了限制，最大只能上传<%=upfilesize%>K的文件！<%=we0%><%
				errs=true
		end if
		if oFileSize=0 then
      			%>请先选择你要上传的文件！<%=we0%><%
				errs=true
		end if


		if errs<>true then
randomize
ranNum=int(90000*rnd)+10000
			filename=year(now)&strMonth&strDay&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt

			ofile.SaveToFile Server.mappath(FilePath&filename)   '保存文件       

	
		set ofile=nothing
     		end if
next
if errs<>true then
bid=upload.form("bid")
if bid="" then bid=0
                If InStr(bid,", ") <= 0 Then
		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select *  FROM qingtian_phoneurl"
		rs.open sql,conn,1,3
		rs.addnew()
			rs("aid")=aid
			rs("bid")=clng(bid)
			rs("fileext")=fileext
			rs("filesize")=int(sizes\(1048576))&"kb"
			rs("fileurl")=FilePath&filename
		rs.update()
		rs.Close
		Set rs = Nothing
                else
                bid=Split(bid,", ")
                for j=0 to ubound(bid) 
                set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select *  FROM qingtian_phoneurl"
		rs.open sql,conn,1,3
		rs.addnew()
			rs("aid")=aid
			rs("bid")=clng(bid(j))
			rs("fileext")=fileext
			rs("filesize")=int(sizes\1048576)&"kb"
			rs("fileurl")=FilePath&filename
		rs.update()
		rs.Close
		Set rs = Nothing
                next
                end if
set upload=nothing 
%>上传软件成功.
<br/>----------------<br/>
<a href='addfilelist1.asp?aid=<%=aid%>&amp;classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回继续上传</a><br/>
<a href='addfilelist.asp?aid=<%=aid%>&amp;classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>直接地址上传</a><br/>
<%	else%>
	<%=qingtian.utf8("系统禁止上传文件!")%><%=we0%>
	<%end if 	
	end  if  
	else%>
	<%=qingtian.utf8("系统禁止上传文件!")%><%=we0%>
	<%end if%>
<a href='filelist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回下载管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function 
%>
<!--#include virtual="/inc/filed.inc"-->